package ie.tippinst.mjp;

import java.util.Iterator;
import java.util.TreeSet;

public class Cell {
	private Integer value; //value in the cell
	private boolean clue;	// cell contains a clue value and CANNOT be modified changed
	private boolean solved;	// cell has been solved
	private TreeSet <Integer> possibles = new TreeSet<Integer>(); // ordered set of possible values
	
	public Cell(int value, boolean clue, int max) {
		this.value = value;
		this.clue = clue;
		if(clue == false)
			addAllPos(max);
	}
	public int getValue() {
		return value;
	}
	public void setValue(int value) {
		this.value = value;
		// need to remember to setSolved as well, if appropriate
	}
	public boolean isClue() {
		return clue;
	}
	public void setClue(boolean clue) {
		this.clue = clue;
	}
	public boolean isSolved() {
		return solved;
	}
	public void setSolved(boolean solved) {
		this.solved = solved;
	}
	public TreeSet<Integer> getPossibles() {
		return possibles;
	}
	public void setPossibles(TreeSet<Integer> possibles) {
		this.possibles = possibles;
	}
	
	public void addPossible(Integer value){
		possibles.add(value);
	}
	
	public void remPossible(Integer value){
		possibles.remove(value);
	}
	
	public void addAllPos(int maxPos){
		// maxPos is max value possible for cell
		//use a loop to add individual values
		for( int i = 1; i <= maxPos; i++)
			possibles.add(i);
	}
	
	public void clrAllPos(){
		possibles.clear();
	}
	public String shwAllPos(){
		String list =""; 
		Iterator<Integer> I = possibles.iterator();
		while(I.hasNext())
			list = I.next() + ",";
		return list;
	}
	@Override
	public String toString() {
		return "Cell [value=" + value + "]";
	}
}
